<template>
  <div class="app-container">
    <div class="container ">
      <el-row :gutter="10" class="filter-container">
        <el-col :span="20">
          <!-- <el-button
            v-waves
            class="filter-item margin-left20"
            type="primary"
            size="mini"
            @click="submitForm('open')"
          >
            <i class="el-icon-circle-plus-outline" />&nbsp;新增
          </el-button> -->
        </el-col>

        <!-- <el-col :span="4" :offset="20">
          <el-input
            v-model="listQuery.search"
            placeholder="请输入软件名称"
            size="mini"
          >
            <i slot="suffix" class="el-input__icon el-icon-search" @click="getListS" />
          </el-input>
        </el-col> -->
      </el-row>
      <div>
        <!-- 删除资产 -->
        <el-dialog
          title="删除资产"
          :visible.sync="delUserdialogV"
          width="25%"
          center
        >
          <div class="text-algin-center">
            <el-avatar :size="60" src="../../assets/icons_slices/img_opo_tip.png">
              <img src="../../assets/icons_slices/img_opo_tip.png">
            </el-avatar>
            <h3>确定删除吗？</h3>
            <span>删除后不可恢复</span>
          </div>
          <span slot="footer" class="dialog-footer">
            <el-button type="danger" size="mini" @click="delUserdialogV = false">删除</el-button>
            <el-button size="mini" @click="delUserdialogV = false">取 消</el-button>
          </span>
        </el-dialog>
        <!-- 回收资产 -->
        <el-dialog
          title="删除明细"
          :visible.sync="recUserdialogV"
          width="25%"
          center
        >
          <div class="text-algin-center">
            <el-avatar :size="60" src="../../assets/icons_slices/img_opo_tip.png">
              <img src="../../assets/icons_slices/img_opo_tip.png">
            </el-avatar>
            <h3>确定删除吗？</h3>
            <!-- <span>回收后已授权软件将不用</span> -->
          </div>
          <span slot="footer" class="dialog-footer">
            <el-button type="danger" size="mini" @click="handleRecover('do')">删除</el-button>
            <el-button size="mini" @click="recUserdialogV = false">取 消</el-button>
          </span>
        </el-dialog>
      </div>
      <!-- <h3>一、软件基本信息</h3> -->
<!--      <el-row style="margin-bottom:20px">-->
<!--        <el-col :span="8" style="text-align: left; padding-right:10px">-->
<!--          <span style="padding-right:10px">1、软件基本信息</span>-->
<!--          <el-select-->
<!--            :disabled="disableSelectDept"-->
<!--            v-model="listQueryS.departId"-->
<!--            placeholder="全部部门"-->
<!--            size="mini"-->
<!--            clearable-->
<!--            @change="queryDepartC1"-->
<!--          >-->
<!--            <el-option-->
<!--              v-for="item in options2"-->
<!--              :key="item.id"-->
<!--              :label="item.name"-->
<!--              :value="item.id"-->
<!--            />-->
<!--          </el-select>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--      <el-table-->
<!--        ref="multipleTable"-->
<!--        v-loading="listLoadingS"-->
<!--        element-loading-text="正在加载中..."-->
<!--        element-loading-background="rgba(0, 0, 0, 0.5)"-->
<!--        :data="listS"-->
<!--        type="index"-->
<!--        border-->
<!--        size="mini"-->
<!--        fit-->
<!--        highlight-current-row-->
<!--        @current-change="handleCurrentChange"-->
<!--      >-->
<!--        <el-table-column label="软件编号" align="center" width="200px">-->
<!--          <template slot-scope="scope">-->
<!--            {{ scope.row.softNumber }}-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column label="软件名称" align="center" width="200px">-->
<!--          <template slot-scope="scope">-->
<!--            {{ scope.row.name }}-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column align="center" label="软件版本" width="230px">-->
<!--          <template slot-scope="scope">-->
<!--            <div class="strinExceeds" :title="scope.row.softVersion">{{ scope.row.softVersion }}</div>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column align="center" label="软件类型" width="200px">-->
<!--          <el-table-column-->
<!--            prop="province"-->
<!--            label="商业软件"-->
<!--            width="100"-->
<!--            align="center"-->
<!--          >-->
<!--            <template slot-scope="scope">-->
<!--              {{ scope.row.typeName == '商业软件'?'√':'' }}-->
<!--            </template>-->
<!--          </el-table-column>-->
<!--          <el-table-column-->
<!--            prop="city"-->
<!--            label="OEM软件"-->
<!--            width="100"-->
<!--            align="center"-->
<!--          >-->
<!--            <template slot-scope="scope">-->
<!--              {{ scope.row.typeName == 'OEM软件'?'√':'' }}-->
<!--            </template>-->
<!--          </el-table-column>-->
<!--          <el-table-column-->
<!--            prop="address"-->
<!--            label="自开发软件"-->
<!--            width="100"-->
<!--            align="center"-->
<!--          >-->
<!--            <template slot-scope="scope">-->
<!--              {{ scope.row.typeName == '自开发软件'?'√':'' }}-->
<!--            </template>-->
<!--          </el-table-column>-->
<!--        </el-table-column>-->
<!--        <el-table-column label="许可数量" align="center" width="200px">-->
<!--          <template slot-scope="scope">-->
<!--            {{ scope.row.permitCount }}-->
<!--          </template>-->
<!--        </el-table-column> &ndash;&gt;-->
<!--        <el-table-column label="可使用版本" align="center" width="230px">-->
<!--          <template slot-scope="scope">-->
<!--            <div class="strinExceeds" :title="scope.row.softVersion">{{ scope.row.softVersion }}</div>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column label="许可期限" align="center" width="220px">-->
<!--          <template slot-scope="scope">-->
<!--            {{ scope.row.permitEndDate }}-->
<!--          </template>-->
<!--        </el-table-column>-->
        <!-- <el-table-column label="备注" align="center" width="200px">
          <template slot-scope="scope">
            {{ scope.row.remark }}
          </template>
        </el-table-column> -->
        <!-- <el-table-column
          label="操作"
          width="200"
          align="center"
          fixed="right"
        >
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="mini"
              @click="handleEdit(scope.$index, scope.row)"
            >编辑</el-button>
            <el-button
              type="danger"
              size="mini"
              @click="handleRecover(scope.$index, scope.row)"
            >回收</el-button>
            <el-button
              type="danger"
              size="mini"
              @click="handleDelete(scope.$index, scope.row)"
            >删除</el-button>
          </template>
        </el-table-column> -->
<!--      </el-table>-->
<!--      <pagination-->
<!--        :total="totalS"-->
<!--        :page.sync="listQueryS.page"-->
<!--        :limit.sync="listQueryS.limit"-->
<!--        :page-sizes="pageSizes"-->
<!--        @pagination="getListS"-->
<!--      />-->
      <!-- <h3>二、软件安装卸载明细</h3> -->
      <!-- <el-button
        type="primary"
        size="mini"
        style="margin-bottom:20px"
        @click="submitForm('open')"
      ><i class="el-icon-circle-plus-outline" />&nbsp;新增明细</el-button> -->
      <el-row>
        <!-- <el-col :span="12">
          <el-button
            v-waves
            class="filter-item margin-left20 upload-demo"
            type="primary"
            size="mini"
            style="margin-bottom:20px"
            @click="outloadFile"
          >
            <i class="el-icon-download" />&nbsp;导出
          </el-button>
        </el-col> -->
        <el-col :span="24" style="text-align: left; padding-right:10px">
<!--          <span style="padding-right:10px">2、软件安装卸载明细</span>-->
<!--          v-if="isManage"-->
          <el-select
            v-show="!disableSelectDept"
            :disabled="disableSelectDept"
            v-model="listQueryS.departId"
            placeholder="全部部门"
            size="mini"
            clearable
            @change="queryDepartC1"
          >
            <el-option
              v-for="item in options2"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
          <el-upload
            v-if="isManage"
            class="upload-demo"
            :show-file-list="false"
            action="http://10.10.10.11:9006/file/upload"
            :before-upload="beforeAvatarUpload"
            :headers="upHeaders"
            accept=".xls,.xlsx"
            :on-success="handleAvatarSuccess"
          >
<!--            v-if="isManage"-->
            <el-button
              v-if="isManage"
              size="mini"
              class="filter-item margin-left20"
              type="primary"
            ><i class="el-icon-circle-plus-outline" />&nbsp;导入</el-button>
          </el-upload>
          <el-button
            v-if="isManage"
            class="filter-item margin-left20 upload-demo"
            type="primary"
            size="mini"
            style="margin-bottom:20px;margin-right:10px"
            @click="outloadFile"
          >
            <i class="el-icon-download" />&nbsp;导出
          </el-button>
<!--          <el-upload-->
<!--            class="upload-demo"-->
<!--            :show-file-list="false"-->
<!--            action="http://10.10.10.11:9006/file/upload"-->
<!--            :before-upload="beforeAvatarUpload"-->
<!--            :headers="upHeaders"-->
<!--            accept=".xls,.xlsx"-->
<!--            :on-success="handleAvatarSuccess"-->
<!--          >-->
<!--            <el-button-->
<!--              v-if="isManage"-->
<!--              size="mini"-->
<!--              class="filter-item margin-left20"-->
<!--              type="primary"-->
<!--            ><i class="el-icon-circle-plus-outline" />&nbsp;导入</el-button>-->
<!--          </el-upload>-->
          <el-button
            v-if="isManage"
            v-waves
            class="filter-item margin-left20 upload-demo"
            type="primary"
            size="mini"
            @click="downloadFile"
          >
            下载导入模板
          </el-button>
<!--          <el-button-->
<!--            v-waves-->
<!--            class="filter-item margin-left20 upload-demo"-->
<!--            type="primary"-->
<!--            size="mini"-->
<!--            @click="otherList"-->
<!--          >-->
<!--            其他台账-->
<!--          </el-button>-->
          <!-- <el-select
            v-model="listQuery.departId"
            placeholder="请选择部门"
            size="mini"
            clearable
            @change="queryDepartC"
          >
            <el-option
              v-for="item in options2"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select> -->
        </el-col>
      </el-row>
      <el-table
        v-loading="listLoading"
        element-loading-text="正在加载中..."
        element-loading-background="rgba(0, 0, 0, 0.5)"
        :data="list"
        type="index"
        border
        size="mini"
        fit
        highlight-current-row
        @current-change="handleCurrentChange2"
      >
        <el-table-column align="center" label="序号">
          <template slot-scope="scope">
            {{ scope.$index+1 + ((listQuery.page-1) * listQuery.limit ) }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="软件编号" width="200px">
          <template slot-scope="scope">
            {{ scope.row.softNumber }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="软件名称" width="200px">
          <template slot-scope="scope">
            {{ scope.row.softName }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="软件版本" width="200px">
          <template slot-scope="scope">
            {{ scope.row.softVersion }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="软件类型" width="200px">
          <template slot-scope="scope">
            {{ scope.row.softTypeName }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="许可数量" width="200px">
          <template slot-scope="scope">
            {{ scope.row.permitCount }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="可使用版本" width="200px">
          <template slot-scope="scope">
            {{ scope.row.useVersionName }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="许可期限" width="200px">
          <template slot-scope="scope">
            {{ scope.row.permitEndDate }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="安装/卸载" width="200px">
          <template slot-scope="scope">
            {{ scope.row.useTypeName }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="计算机编号" width="200px">
          <template slot-scope="scope">
            {{ scope.row.deviceNumber }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="计算机品牌" width="200px">
          <template slot-scope="scope">
            {{ scope.row.brandName }}
          </template>
        </el-table-column>
        <el-table-column label="使用人" align="center">
          <template slot-scope="scope">
            {{ scope.row.userName }}
          </template>
        </el-table-column>
        <el-table-column label="使用部门" align="center" width="200px">
          <template slot-scope="scope">
            {{ scope.row.deptName }}
          </template>
        </el-table-column>
        <el-table-column label="安装/卸载版本" align="center" width="220px">
          <template slot-scope="scope">
            {{ scope.row.softVersion }}
          </template>
        </el-table-column>
<!--        <el-table-column label="安装" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            {{ scope.row.useType == 1?'√':'' }}-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column label="卸载" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            {{ scope.row.useType == 2?'√':'' }}-->
<!--          </template>-->
<!--        </el-table-column>-->
        <el-table-column label="安装/卸载日期" align="center" width="220px">
          <template slot-scope="scope">
            {{ scope.row.operateDate?scope.row.operateDate.slice(0,10):'' }}
          </template>
        </el-table-column>
<!--        <el-table-column label="安装数量" align="center" width="120px">-->
<!--          <template slot-scope="scope">-->
<!--            {{ scope.row.installCount }}-->
<!--          </template>-->
<!--        </el-table-column>-->
        <!-- <el-table-column label="备注" align="center" width="200px">
          <template slot-scope="scope">
            {{ scope.row.remark }}
          </template>
        </el-table-column> -->
        <el-table-column
          v-if="isManage"
          label="操作"
          width="100"
          align="center"
          fixed="right"
        >
          <template slot-scope="scope">
<!--            <el-button-->
<!--              type="primary"-->
<!--              size="mini"-->
<!--              @click="handleEdit(scope.$index, scope.row)"-->
<!--            >编辑</el-button>-->
            <el-button
              type="danger"
              size="mini"
              @click="handleRecover(scope.$index, scope.row)"
            >删除</el-button>
            <!-- <el-button
              type="danger"
              size="mini"
              @click="handleDelete(scope.$index, scope.row)"
            >删除</el-button> -->
          </template>
        </el-table-column>
      </el-table>
      <pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
    <!-- 添加用户弹框 -->
    <el-dialog
      :title="titleStatus"
      :visible.sync="addUserdialogV"
      width="80%"
      :before-close="handleClose"
      center
    >
      <el-form
        ref="ruleForm"
        class="formInner"
        :rules="rules"
        label-width="120px"
        size="mini"
        :inline="true"
        :model="formAddUser"
      >
        <el-row>
          <el-col :span="8">
            <el-form-item
              v-if="(!isUserEdit && isUserEdit !=null) || editPassword"
              label="安装/卸载:"
              prop="useType"
            >
              <el-select v-model="formAddUser.useType" placeholder="请选择">
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="计算机编号:" prop="deviceNumber">
              <el-input v-model="formAddUser.deviceNumber" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="计算机品牌:" prop="brandName">
              <el-input v-model="formAddUser.brandName" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="使用人:" prop="userName">
              <el-input v-model="formAddUser.userName" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              v-if="(!isUserEdit && isUserEdit !=null) || editPassword"
              label="使用部门:"
              prop="deptId"
            >
              <el-select v-model="formAddUser.deptId" placeholder="请选择部门">
                <el-option
                  v-for="item in options2"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="安装/卸载版本:" prop="softVersion">
              <el-input v-model="formAddUser.softVersion" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="安装数量:" prop="installCount">
              <el-input
                v-model="formAddUser.installCount"
                type="number"
                min="0"
                onkeyup="value=value.replace('-','')"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              v-if="(!isUserEdit && isUserEdit !=null) || editPassword"
              label="安装/卸载日期:"
              prop="operateDate"
            >
              <div class="block">
                <el-date-picker
                  v-model="formAddUser.operateDate"
                  style="width:85%"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择日期"
                />
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" size="mini" @click="submitForm('ruleForm')">确 定</el-button>
        <el-button size="mini" @click="handleClose">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { assetweihuPage, assetweihuAdd, assetweihuDel,
  assetweihuPut, assetsImport, softList, assetsExport } from '@/api/assetweihuSoft'
import Pagination from '@/components/Pagination'
import {
  departmentList
} from '@/api/department'
import { getToken } from '@/utils/auth'
import { userList, userAdd
  , userDel, userPut, userPermission, userPasswordPut } from '@/api/user'
import { getCookie, setCookie, removeCookie } from '@/utils/cookie'
import { mapGetters } from 'vuex'
export default {
  computed: {
    ...mapGetters([
      'name',
      'userInfo'
    ]),
    isManage() {
      // if (getCookie('userInfo')) {
      //   return JSON.parse(getCookie('userInfo')).roleType === 1024
      // } else {
      //   return this.userInfo.roleType === 1024
      // }
      if (getCookie('userInfo')) {
        return JSON.parse(getCookie('userInfo')).roleType === 1024 ||
          JSON.parse(getCookie('userInfo')).roleType === 1025
      } else {
        return false
      }
    }
  },
  components: { Pagination },
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'gray',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      upHeaders: {
        ACCESS_TOKEN: getToken()
      },
      pageSizes: [5, 10, 15, 20],
      recUserdialogV: false,
      datevalue2: null,
      datevalue1: null,
      isUserEdit: false,
      titleStatus: '新增明细',
      rules: {
        softVersion: [
          { required: true, message: '请输入内容', trigger: 'blur' }
        ],
        userName: [
          { required: true, message: '请输入内容', trigger: 'blur' }
        ],
        installCount: [
          { required: true, message: '请输入内容', trigger: 'blur' }
        ],
        useType: [
          { required: true, message: '请选择', trigger: 'blur' }
        ],
        deptId: [
          { required: true, message: '请选择', trigger: 'blur' }
        ],
        operateDate: [
          { required: true, message: '请选择', trigger: 'blur' }
        ],
        deviceNumber: [
          { required: true, message: '请输入内容', trigger: 'blur' }
        ],
        brandName: [
          { required: true, message: '请输入内容', trigger: 'blur' }
        ],
        phone: [
          { required: true, message: '请输入手机号', trigger: 'blur' },
          { min: 11, max: 11, message: '手机号长度不对', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '请输入内容', trigger: 'blur' },
          { min: 2, max: 25, message: '长度在 6 到 25 个字符', trigger: 'blur' }
        ]
      },
      formAddUser: {
        'brandName': '',
        'deptId': '',
        'deptName': '',
        'deviceNumber': '',
        'id': '',
        'installCount': 0,
        'networkType': '0',
        'operateDate': '',
        'remark': '',
        'softFrom': '0',
        'softId': '0',
        'softName': '',
        'softTypeId': '1',
        'softTypeName': '',
        'softVersion': '',
        'useType': 1,
        'userId': '',
        'userName': ''
      },
      addUserdialogV: false,
      delUserdialogV: false,
      value1: '1',
      value2: '1',
      total: 10,
      list: [],
      listLoading: false,
      listLoadingS: false,
      disableSelectDept: false, // 是否可选择部门
      listQuery: {
        departId: '',
        search: '',
        page: 1,
        limit: 10,
        menuFrom: 1,
        softId: ''
      },
      listQueryS: {
        departId: '',
        search: '',
        page: 1,
        limit: 5,
        menuFrom: 1
      },
      options: [{
        value: '1',
        label: '商业软件'
      }, {
        value: '2',
        label: 'OEM软件'
      }, {
        value: '3',
        label: '自开发软件'
      }],
      options1: [{
        value: 1,
        label: '安装'
      }, {
        value: 2,
        label: '卸载'
      }],
      options2: [{
        id: '1',
        name: '综合管理部'
      }, {
        id: '2',
        name: '总调度中心'
      }, {
        id: '3',
        name: '计划合同部'
      }],
      listS: [],
      isOther: false,
      totalS: 0,
      editPassword: false,
      value: '1',
      cacheId: null,
      checkId: null,
      multipleSelection: {}
    }
  },
  created() {
    // this.fetchData()
    this.getDepartmentList()
  },
  methods: {
    queryDepartC() {
      this.getList()
    },
    queryDepartC1(id) {
      console.log('选中的部门id')
      // this.getListS()
      this.getList()
    },
    getDepartmentList() {
      departmentList({
        limit: 50,
        page: 1
      }).then(res => {
        if (res.code === 200) {
          this.options2 = []
          // this.options10 = [{
          //   id: '0',
          //   name: '公司全体'
          // }]
          res.data.data.map(item => {
            if (item.id !== '1025' && item.id !== '55904214559285248') {
              // this.options10.push(item)
              this.options2.push(item)
            }
          })
          if (this.options2.length === 1) {
            this.listQueryS.departId = this.options2[0].id
            this.disableSelectDept = true
          } else {
            this.disableSelectDept = false
          }
          this.fetchData()
        }
      })
    },
    downloadFile() {
      const link = document.createElement('a')
      link.style.display = 'none'
      link.setAttribute('download', '正版软件维护台账-模板')
      link.href = 'http://10.10.10.11:9006/upload/%E6%A8%A1%E6%9D%BF-%E8%BD%AF%E4%BB%B6%E7%BB%B4%E6%8A%A4%E5%8F%B0%E8%B4%A6.xlsx'
      document.body.appendChild(link)
      link.click()
    },
    outloadFile() {
      this.listQuery.departId = this.listQueryS.departId
      assetsExport(this.listQuery).then(res => {
        if (res.code === 200) {
          // this.getList()
          const link = document.createElement('a')
          link.style.display = 'none'
          link.setAttribute('download', '信息化固定资产管理台帐')
          link.href = res.message
          document.body.appendChild(link)
          link.click()
          // window.open(res.message)
        }
      })
    },
    beforeAvatarUpload(file) {
      const isJPG = file.name.indexOf('xls')
      const isLt2M = file.size / 1024 / 1024 < 200
      if (!isJPG) {
        this.$message.error('上传只能是Excel文件!')
      }
      if (!isLt2M) {
        this.$message.error('上传文件大小不能超过 200MB!')
      }
      return isJPG && isLt2M
    },
    handleAvatarSuccess(response, file, fileList) {
      if (response && response.code === 200) {
        this.listLoading = true
        assetsImport({
          filePath: response.data
        }).then(res => {
          if (res.code === 200) {
            this.listLoading = false
            this.$message.success('导入维护台账申请成功')
          }
        })
        // this.ruleForm.logo = response.data
        // this.logoUrl = URL.createObjectURL(file.raw)
      } else {
        this.$message.warning('请求异常')
      }
    },
    handleCurrentChange(val, val1) {
      this.listQuery.softId = val.id
      this.getList()
      this.multipleSelection = val
    },
    handleCurrentChange2(val, val1) {
      console.log('this.isOther', this.isOther)
      if (!this.isOther) {
        return
      }
      console.log('val', val)
      console.log('val1', val1)
      const row = {
        softNumber: '无编号',
        name: val.softName,
        softVersion: val.softVersion,
        typeName: val.softTypeName,
        permitCount: '',
        permitEndDate: ''
      }
      this.listS = [row]
    },
    toggleSelection(rows) {
      this.listQuery.softId = rows.id
      this.getList()
      this.$refs.multipleTable.setCurrentRow(rows)
    },
    initData() {
      if (this.$refs.ruleForm) {
        this.$refs.ruleForm.clearValidate()
      }
      this.formAddUser = {
        'brandName': '',
        'deptId': '',
        'deptName': '',
        'deviceNumber': '',
        'id': '',
        'installCount': 0,
        'networkType': '0',
        'operateDate': '',
        'remark': '',
        'softFrom': '0',
        'softId': '0',
        'softName': '',
        'softTypeId': '0',
        'softTypeName': '',
        'softVersion': '',
        'useType': 1,
        'userId': '',
        'userName': ''
      }
    },
    handleClose(params) {
      this.initData()
      this.getList()
      this.addUserdialogV = false
    },
    submitForm(formName, editPassword) {
      if (formName === 'open') {
        this.initData()
        this.titleStatus = '新增明细'
        this.formAddUser.userName = ''
        this.formAddUser.phone = ''
        this.addUserdialogV = true
        this.formAddUser.id = ''
        this.isUserEdit = false
      } else {
        if (this.formAddUser.id !== '') {
          this.$refs['ruleForm'].validate((valid) => {
            if (valid) {
              assetweihuPut(this.formAddUser).then(res => {
                if (res.code === 200) {
                  this.imageUrl = ''
                  this.addUserdialogV = false
                  this.initData()
                  this.getList()
                }
              })
            }
          })
        } else {
          this.$refs[formName].validate((valid) => {
            if (valid) {
              assetweihuAdd(this.formAddUser).then(res => {
                if (res.code === 200) {
                  this.addUserdialogV = false
                  this.initData()
                  this.getList()
                }
              })
              // alert('submit!')
            } else {
              return false
            }
          })
        }
      }
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    },
    handleEdit(index, row) {
      this.titleStatus = '修改明细'
      this.addUserdialogV = true
      this.formAddUser = row
    },
    handleRecover(index, row) {
      if (index == 'do') {
        // this.$confirm('确定删除吗？', {
        //   confirmButtonText: '确定',
        //   cancelButtonText: '取消',
        //   type: 'warning'
        // }).then(() => {
        assetweihuDel(
          {
            ids: this.cacheId
          }
        ).then(res => {
          if (res.code == 200) {
            this.recUserdialogV = false
            this.$message.success('删除成功')
            this.getList()
          }
        })
        // }).catch(() => {
        //   this.$message.info('已点击取消')
        // })
      } else {
        this.recUserdialogV = true
        this.cacheId = row.id
      }
    },
    handleDelete(index, row) {
      this.delUserdialogV = true
    },
    getList() {
      this.listQuery.departId = this.listQueryS.departId
      this.listLoading = true
      assetweihuPage(this.listQuery).then(response => {
        this.list = response.data.data
        this.total = response.totalCount || 0
        this.listLoading = false
      })
    },
    getListS() {
      this.isOther = false
      this.listLoadingS = true
      softList(this.listQueryS).then(response => {
        if (response.data && response.data.data[0]) {
          this.toggleSelection(response.data.data[0])
          this.listS = response.data.data
          this.totalS = response.totalCount || 0
        }
        this.listLoadingS = false
      })
    },
    fetchData() {
      this.getList()
      // this.getListS()
    },
    otherList() {
      // this.$nextTick(function() {
      //   this.$refs.multipleTable.clearSelection()
      // })
      this.isOther = true
      this.$refs.multipleTable.clearSelection()
      this.$refs.multipleTable.setCurrentRow({})
      this.multipleSelection = {}
      this.listQuery.softId = -1
      this.getList()
    }
  }
}
</script>
<style>
  .el-table th > .cell > .el-checkbox {
    display: none;
  }
  .filter-container{
    margin-bottom: 20px;
  }
</style>
<style scoped>
  /deep/.formInner {
     .el-select>.el-input {
      width: 166px;
    }
  }
  /deep/.el-table__body tr.current-row>td{
    background-color: rgb(64, 158, 255) !important;
    color: #fff;
  }
  .upload-demo{
    display: inline;
    margin-left: 10px;
  }
  .text-algin-center {
    text-align: center;
  }
  .container {
    padding: 0px 20px 20px 20px !important;
  }
</style>
